package org.hy.domain.ug;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 发布信息的简单模型类.可理解成feed.<br>
 * 此类为抽象基类,被UPost类继承.
 * @author xwm
 *
 */
public abstract class Post {
	
	private Integer id;
	
	
	private Object poster;/*User或GMember对象*/
	
	private MultiContent content;
	
	private Integer visibility;
	
	private Date intime;
	

	
	public Post() {
		
	}
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Object getPoster() {
		return poster;
	}
	
	public void setPoster(Object poster) {
		//mybatis的对查询结果以list的形式缓存。
		List postList = null;
		if(List.class.isAssignableFrom(poster.getClass())){
			//System.out.println("poster is cached for list...");
			postList = (List)poster;
			if(postList.size()>0)poster = postList.get(0);
		}
		this.poster = poster;
	}
	
	public MultiContent getContent() {
		return content;
	}
	public void setContent(MultiContent content) {
		this.content = content;
	}
	
	public void setContent(String content) {
		MultiContent mc = new MultiContent();
		mc.setText(content);
		this.content = mc;
	}
	
	public Integer getVisibility() {
		return visibility;
	}
	public void setVisibility(Integer visibility) {
		this.visibility = visibility;
	}
	public Date getIntime() {
		return intime;
	}
	public void setIntime(Date intime) {
		this.intime = intime;
	}
	
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
		/*buildToString(builder);
		return builder.toString();*/
	}
	
	public  void buildToString(ToStringBuilder builder) {
		builder.append("id",id).append("poster",poster).append("content",content);
	}
	

	
}
